package algorithms.beans;

import lombok.*;

@Setter
@Getter
@AllArgsConstructor
@NoArgsConstructor
@ToString
public class Student implements Comparable<Student> {

    private String name;
    private int score;


    // 定义Student的compareTo函数
    // 如果分数相等，则按照名字的字母序排序
    // 如果分数不等，则分数高的靠前
    @Override
    public int compareTo(Student that) {

        if( this.score < that.score )
            return -1;
        else if( this.score > that.score )
            return 1;
        else // this.score == that.score
            return this.name.compareTo(that.name);
    }
}
